﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" 
Inherits="Nivdal.Live" Theme="SkinFile" Codebehind="Live.aspx.cs" %>

<%@ Register Assembly="obout_Flyout2_NET" Namespace="OboutInc.Flyout2" TagPrefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadPlaceHolder" Runat="Server">
    <script type="text/javascript">
        function ShowDiv(name)
        {
            document.getElementById(name).style.visibility = "visible";
        }
        function HideDiv(name)
        {
            document.getElementById(name).style.visibility = "hidden";
        }
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    
    <asp:HiddenField ID="UserIdHiddenField" runat="server" />
    <asp:HiddenField ID="IsPremiumHiddenField" runat="server" />
    <asp:UpdatePanel ID="LiveUpdatepanel" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="MinuteCounter" EventName="Tick" />
    </Triggers>
    <ContentTemplate>
        <div class="basic_element">
        <div class="red_title">
           <asp:Label ID="PageTitlelLabel" runat="server" Text="<%$ Resources:Resource, Live_LiveMatchesTitle %>" CssClass="white_title"></asp:Label> 
        </div>
        <div class="padding5">

        
        <asp:Timer ID="MinuteCounter" runat="server" Interval="60000" OnTick="RefreshView" > 
        </asp:Timer>
        <asp:ListView ID="LiveMatchesListView" runat="server" DataSourceID="LiveDataSource" OnItemCommand="LiveItemCommandHandler">
            <LayoutTemplate>
                <div style="display:inline;">
                <asp:Image ID="itemplaceholder" runat="server" />          
                </div>
            </LayoutTemplate>
            <ItemTemplate>
                <div class="floater">
                <table style="width:286px; vertical-align:middle; margin:5px 5px 5px 5px; display:inline;" cellpadding="0" cellspacing="0">
                    <tr>
                        <td style="width:88px; text-align:center; background-color:#F4F3F3; padding:2px;">
                            <asp:HyperLink ID="HomeTeamHyperlink" runat="server" CssClass="TeamLinkInMatchStyle" Text='<%# Eval("HomeTeamName") %>'
                             NavigateUrl='<%# ((bool)Eval("IsNationalTeamsMatch") ? "~/NationalTeam.aspx?Id=" : "~/TeamHomePage.aspx?TeamId=" ) + Eval("HomeTeamId") %>'></asp:HyperLink>
                             <br />
                             <asp:Image ID="HomeTeamLogo" runat="server" ImageUrl='<%# Eval("HomeTeamLogo") %>' Width="48" Height="48" />                               
                        </td>
                        <td style="width: 110px; background-color:#F4F3F3; padding:2px;">
                            <asp:HiddenField ID="MatchIdHiddenfiled" runat="server" Value='<%# Eval("MatchId") %>' />                            
                            <asp:HiddenField ID="LanguageHiddenField" runat="server" Value='<%# Eval("Language") %>' />
                            <asp:HiddenField ID="LiveIdHiddenField" runat="server" Value='<%# Eval("LiveId") %>' />
                            <div style="width:100%; text-align:center;">
                                <asp:ImageButton ID="BookmarkImageButton" runat="server" ImageUrl="~/Images/bookmarks.png" Visible='<%# UserPremium() %>' 
                                CommandName="Bookmark" CommandArgument='<%# Eval("MatchId") %>' ToolTip="<%$ Resources:Resource, MatchPage_BookmarkLinkButtonToolTip %>" />
                                &nbsp;
                                <asp:Label ID="CurrentMinuteLabel" runat="server" Text='<%# Eval("CurrentMinute") + "`" %>'></asp:Label>
                                &nbsp;
                                <asp:HyperLink ID="ListOfEventsImage" runat="server" ImageUrl="~/Images/Icons/LiveDetails.png" 
                                NavigateUrl='<%# "MatchPage.aspx?MatchId=" + Eval("MatchId") %>' ></asp:HyperLink>
                                &nbsp;
                                <%--<div onmouseover="<%# "ShowDiv('div" + Eval("MatchId").ToString() + "')" %>"
                                 onmouseout="<%# "HideDiv('div" + Eval("MatchId") + "')" %>" style="display:inline; width:16px; height:16px;">
                                    <span id='<%# "div" + Eval("MatchId") %>' style="visibility:hidden;">--%>
                                        <asp:ImageButton ID="DeleteImageButton" runat="server" ToolTip="<%$Resources:Resource, Live_RemoveMatchFromLiveToolTip %>"
                                         CommandName="Remove" CommandArgument='<%# Eval("LiveId") %>' ImageUrl="~/Images/Icons/delete.png" />                            
                                    <%--</span>
                                </div>  --%>
                            </div>
                            <asp:Panel ID="RegularPanel" runat="server" Visible='<%# RegularBackgroundVisible(Eval("HomeTeamScored"), Eval("AwayTeamScored")) %>'>
                                <table style="width:100%;background-image:url('Images/MatchIcons/resultbg.png'); background-position:center;
                                 background-repeat:no-repeat; text-align:center;" >
                                    <tr>
                                        <td style="width:50%; padding:5px; text-align:center;">
                                            <asp:Label ID="HomeTeamScoreLabel1" runat="server" Text='<%# Eval("HomeTeamScore") %>' SkinID="MatchResultLabel" />
                                        </td>
                                        <td style="width:50%; text-align:center; padding:5px;">
                                            <asp:Label ID="AwayTeamScoreLabel1" runat="server" Text='<%# Eval("AwayTeamScore") %>' SkinID="MatchResultLabel" />
                                        </td>
                                    </tr>
                                </table>
                            </asp:Panel>
                            <asp:Panel ID="HomeScoredPanel" runat="server" Visible='<%# HomeBackgroundVisible(Eval("HomeTeamScored"), Eval("AwayTeamScored")) %>' >
                                <table style="width:100%; background-image:url('Images/MatchIcons/resultbg_Home.png'); background-position:center;
                                    background-repeat:no-repeat;text-align:center;">
                                    <tr>
                                        <td style="width:50%; padding:5px; text-align:center;">
                                            <asp:Label ID="HomeTeamScoreLabel2" runat="server" Text='<%# Eval("HomeTeamScore") %>' SkinID="MatchResultScoredLabel" Visible='<%# DirLTR() %>' />
                                            <asp:Label ID="HomeTeamScoreLabel2rtl" runat="server" Text='<%# Eval("HomeTeamScore") %>' SkinID="MatchResultScoredLabel" Visible='<%# !(bool)DirLTR() %>' />
                                        </td>
                                        <td style="width:50%; text-align:center; padding:5px;">
                                            <asp:Label ID="AwayTeamScoreLabel2" runat="server" Text='<%# Eval("AwayTeamScore") %>' SkinID="MatchResultLabel" />
                                        </td>
                                    </tr>
                                </table>
                            </asp:Panel>
                            <asp:Panel ID="AwayScoredPanel" runat="server" Visible='<%# AwayBackgroundVisible(Eval("HomeTeamScored"), Eval("AwayTeamScored")) %>' > 
                                <table style="width:100%; background-image:url('Images/MatchIcons/resultbg_Away.png'); background-position:center; 
                                    background-repeat:no-repeat;text-align:center;"> 
                                    <tr>
                                        <td style="width:50%; padding:5px; text-align:center;">
                                            <asp:Label ID="HomeTeamScoreLabel3" runat="server" Text='<%# Eval("HomeTeamScore") %>' SkinID="MatchResultLabel" />
                                        </td>
                                        <td style="width:50%; text-align:center; padding:5px;">
                                            <asp:Label ID="AwayTeamScoreLabel3" runat="server" Text='<%# Eval("AwayTeamScore") %>' SkinID="MatchResultScoredLabel" />
                                        </td>
                                    </tr>
                                </table>
                            </asp:Panel>
                            <asp:Panel ID="BothScoredPanel" runat="server" Visible='<%# BothBackgroundVisible(Eval("HomeTeamScored"), Eval("AwayTeamScored")) %>' >
                                <table style="width:100%; background-image:url('Images/MatchIcons/resultbg_Both.png'); background-position:center; 
                                    background-repeat:no-repeat;text-align:center;"> 
                                    <tr>
                                        <td style="width:50%; padding:5px; text-align:center;">
                                            <asp:Label ID="HomeTeamScoreLabel4" runat="server" Text='<%# Eval("HomeTeamScore") %>' SkinID="MatchResultScoredLabel" />
                                        </td>
                                        <td style="width:50%; text-align:center; padding:5px;">
                                            <asp:Label ID="AwayTeamScoreLabel4" runat="server" Text='<%# Eval("AwayTeamScore") %>' SkinID="MatchResultScoredLabel" />
                                        </td>
                                    </tr>
                                </table>
                            </asp:Panel>
                            
                            
                            <cc1:Flyout ID="MatchEvents" runat="server" AttachTo="ListOfEventsImage" NoneEffect="true" Position="MIDDLE_RIGHT">
                                <div>
                                    <asp:ListView ID="LatestEventsListView" runat="server" DataSourceID="LatestEventsDataSource">
                                        <LayoutTemplate>
                                            <div class="ToolTipStyle">
                                                <asp:Label ID="LatestEventsTitleLabel" runat="server" SkinID="InfoLabel"
                                                Text='<%# Resources.Resource.Global_LatestEvents+ ":"%>'> </asp:Label>
                                                <br />
                                                <asp:Label ID="itemplaceholder" runat="server"></asp:Label>
                                            </div>
                                        </LayoutTemplate>
                                        <ItemTemplate>
                                            <div style="width:300px;">
                                            <asp:Image ID="EventTypeImage" runat="server" ImageUrl='<%# "~/Images/MatchIcons/" + Eval("IconName") %>' Height="20" Width="18" />
                                            <asp:Label ID="MinuteLabel" runat="server" Text='<%# MinuteSting(Eval("Minute"))%>' SkinID="InfoLabel"></asp:Label>
                                            <asp:Label ID="EventText" runat="server" Text='<%# Eval("EventText") %>' SkinID="GridLabel"></asp:Label>
                                            </div>
                                        </ItemTemplate>                                    
                                        <EmptyDataTemplate>
                                            <div class="ToolTipStyle">
                                                <asp:Label ID="NotStartedLabel" runat="server" Text="<%$Resources:Resource, Live_MatchNotStartedLabelTest %>"
                                                 SkinID="GridLabel"></asp:Label>
                                            </div>
                                        </EmptyDataTemplate>
                                        <ItemSeparatorTemplate><br /></ItemSeparatorTemplate>
                                    </asp:ListView> 
                                    <asp:SqlDataSource ID="LatestEventsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                                     SelectCommand="Nivdal_GetMatchLatestEventsForLive" SelectCommandType="StoredProcedure">
                                        <SelectParameters>
                                            <asp:ControlParameter ControlID="MatchIdHiddenfiled" PropertyName="Value" Type="String" Name="MatchId" />
                                            <asp:ControlParameter ControlID="LanguageHiddenField" PropertyName="Value" Type="Decimal" Name="Language" />
                                        </SelectParameters> 
                                    </asp:SqlDataSource> 
                                </div>                            
                            </cc1:Flyout>                         
                        </td>
                        <td style="width:88px; text-align:center;background-color:#F4F3F3; padding:2px;">
                            <asp:HyperLink ID="AwayTeamLink" runat="server" CssClass="TeamLinkInMatchStyle" Text='<%# Eval("AwayTeamName") %>'
                             NavigateUrl='<%# ((bool)Eval("IsNationalTeamsMatch") ? "~/NationalTeam.aspx?Id=" : "~/TeamHomePage.aspx?TeamId=" ) + Eval("AwayTeamId") %>'></asp:HyperLink>
                             <br />
                             <asp:Image ID="AwayTeamLogoImage" runat="server" ImageUrl='<%# Eval("AwayTeamLogo") %>' Width="48" Height="48" />
                        </td>
                    </tr>   
                </table>  
                </div>                                 
            </ItemTemplate>
            <EmptyDataTemplate>
                <asp:Label ID="NoLiveMatchesLabel" runat="server" Text="<%$Resources:Resource, Live_NoLiveMatches %>" SkinID="GridLabel"></asp:Label>
            </EmptyDataTemplate>            
        </asp:ListView>
        <asp:SqlDataSource ID="LiveDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
         SelectCommand="Nivdal_GetLiveMatchesFullData" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:ControlParameter ControlID="UserIdHiddenField" PropertyName="Value" Type="String" Name="UserId" />
            </SelectParameters> 
        </asp:SqlDataSource> 
        <div class="clearBoth"></div>
        <br />
        <asp:Button ID="RemoveAllButton" runat="server" CssClass="GreenSmallButtonStyle" OnClick="RemoveAll"
         Message="<%$Resources:Resource, Live_DeleteAllButtonSureMessage %>" Text="<%$Resources:Resource, Global_DeleteAll %>"
         OnClientClick="return confirm(this.getAttribute('Message'))" />
        </div>
        </div>
    </ContentTemplate>
    </asp:UpdatePanel>
    
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="PageNamePlaceHolder" Runat="Server">
    <asp:Label ID="PageNameLabel" runat="server" Text="<%$ Resources:Resource, Live_PageName %>" CssClass="PageNameContentStyle"></asp:Label>    
</asp:Content>

